package com.os.opencv.java.chapter4;

import org.opencv.core.Core;
import org.opencv.core.CvType;
import org.opencv.core.Mat;

public class Divide {

    public static void main(String[] args) {
        System.loadLibrary(Core.NATIVE_LIBRARY_NAME);

        //填充矩阵1的数据并在控制台输出
        Mat mat1 = new Mat(1, 9, CvType.CV_8UC1);
        byte[] b1 = new byte[]{1,2,3,4,5,6,7,8,9};
        mat1.put(0,0,b1);
        System.out.println("mat1-CV_8UC1:");
        System.out.println(mat1.dump());

        //填充矩阵2的数据并在控制台输出
        Mat mat2 = new Mat(1, 9, CvType.CV_8UC1);
        byte[] b2 = new byte[]{1,1,1,2,2,2,3,3,3};
        mat2.put(0,0,b2);
        System.out.println("mat2-CV_8UC1:");
        System.out.println(mat2.dump());

        //将矩阵1和矩阵2点除并在控制台输出
        Mat dst = new Mat();
        System.out.println("mat1/mat2(CV_8UC1):");
        Core.divide(mat1, mat2, dst);
        System.out.println(dst.dump());

        //将矩阵1的数据类型转换成CV_32FC1
        mat1.convertTo(mat1, CvType.CV_32FC1);
        System.out.println("mat1(CV_32FC1):");
        System.out.println(mat2.dump());

        //将矩阵2的数据类型转换成CV_32FC1并在控制台输出
        mat2.convertTo(mat2, CvType.CV_32FC1);
        System.out.println("mat2(CV_32FC1):");
        System.out.println(mat2.dump());

        //将dst的数据类型转换成CV_32FC1
        dst.convertTo(dst, CvType.CV_32FC1);

        //将矩阵1和矩阵2点除并在控制台输出
        Core.divide(mat1, mat2, dst);
        System.out.println("mat1/mat2(CV_32FC1):");
        System.out.println(dst.dump());



    }
}
